package com.example.cyw.sqlhelper;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

public class MyAdapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<Comcont> mlist;
    public MyAdapter(Context mContext,ArrayList<Comcont> mlist){
        this.mContext=mContext;
        this.mlist=mlist;

    }
    @Override
    public int getCount() {
        return mlist.size();
    }

    @Override
    public Object getItem(int position) {
        return mlist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Viewholder holder;
        if (convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(R.layout.card_item,parent,false);
            holder=new Viewholder();
            holder.comment=convertView.findViewById(R.id.tv_comcont);
            convertView.setTag(holder);
        }
        holder= (Viewholder) convertView.getTag();
        holder.comment.setText( mlist.get(position).getComcont());
        return convertView;
    }
    class Viewholder{
        private TextView comment;
    }
}
